<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.org/ui">

    <h:form id="EmailListForm">

        <p:panel header="#{bundle.ListEmailTitle}">
            <p:dataTable id="datalist" value="#{emailController.items}" var="item"
                         selectionMode="single" selection="#{emailController.selected}"
                         rowKey="#{item.id}"
                         paginator="true"
                         rows="10"
                         rowsPerPageTemplate="10,20,30"
                         >

                <p:ajax event="rowSelect"   update="createButton viewButton editButton deleteButton"/>
                <p:ajax event="rowUnselect" update="createButton viewButton editButton deleteButton"/>

                <p:column sortBy="#{item.id}" filterBy="#{item.id}">
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListEmailTitle_id}"/>
                    </f:facet>
                    <h:outputText value="#{item.id}"/>
                </p:column>
                <p:column sortBy="#{item.email}" filterBy="#{item.email}">
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListEmailTitle_email}"/>
                    </f:facet>
                    <h:outputText value="#{item.email}"/>
                </p:column>
                <p:column sortBy="#{item.pessoa.id}" filterBy="#{item.pessoa.id}">
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListEmailTitle_pessoa}"/>
                    </f:facet>
                    <h:outputText value="#{item.pessoa.id}"/>
                </p:column>
                <f:facet name="footer">
                    <div class="footer-section">
                        <p:commandButton id="createButton" icon="ui-icon-plus"   value="#{bundle.Create}" actionListener="#{emailController.prepareCreate}" update=":EmailCreateForm" oncomplete="EmailCreateDialog.show()"/>
                        <p:commandButton id="viewButton"   icon="ui-icon-search" value="#{bundle.View}" update=":EmailViewForm" oncomplete="EmailViewDialog.show()" disabled="#{empty emailController.selected}"/>
                        <p:commandButton id="editButton"   icon="ui-icon-pencil" value="#{bundle.Edit}" update=":EmailEditForm" oncomplete="EmailEditDialog.show()" disabled="#{empty emailController.selected}"/>
                        <p:commandButton id="deleteButton" icon="ui-icon-trash"  value="#{bundle.Delete}" actionListener="#{emailController.delete}" update=":growl,datalist" disabled="#{empty emailController.selected}">
                            <p:confirm header="#{bundle.ConfirmationHeader}" message="#{bundle.ConfirmDeleteMessage}" icon="ui-icon-alert"/>
                        </p:commandButton>
                    </div>
                </f:facet>

            </p:dataTable>

        </p:panel>
        <ui:include src="/WEB-INF/include/confirmation.xhtml"/>
    </h:form>

</ui:composition>